import React from 'react'
import { useLocation } from 'react-router-dom'
import styles from './index.module.css'
import { useSelector, useDispatch } from 'react-redux'
import { editdate } from '../../store/CitySlice'
import { Button } from 'antd-mobile'
import dayjs from 'dayjs'
function Index() {
  const { state } = useLocation()
  console.log(state);
  const { date } = useSelector((state) => state.CitySlice)
  const dispatch = useDispatch()

  const handledate = (val) => {
    dispatch(editdate({date:dayjs(val).format('MM-DD')}))
  }

  return (
    <div>
      <div className={styles.date_wroe}>
        <span>
          <Button size='middle' color='primary' onClick={() => handledate(-1)}>
            前一天
          </Button>
        </span>
        <span>{date}</span>
        <span>
          <Button size='middle' color='primary' onClick={() => handledate(+1)}>
            后一天
          </Button>
        </span>
      </div>
      <div className={styles.box_wroe}>
        <div className={styles.left_wroe}>
          <span>{state.start}</span>
          <span>{state.startTime}</span>
          <span>{state.end}</span>
          <span>商务票<b>有票</b></span>
          <span>一等票<b>有票</b></span>
          <span>二等票<b>有票</b></span>
        </div>
        <div className={styles.right_wroe}>
          <span>￥{state.tick?.vip}</span>
        </div>
      </div>
    </div>
  )
}

export default Index
